<template>
    <div style="width: 100%; height: 100vh;background-color: skyblue;overflow: hidden">
      <div style="width: 400px; margin: 100px auto">
        <div style="color: rgba(180,140,215,0.62);font-size: 30px;text-align: center;padding: 30px 0">欢迎登录</div>
        <el-form :model="form" size="normal" >
          <el-form-item>
            <el-input :prefix-icon="Avatar" v-model="form.username"/>
          </el-form-item>
          <el-form-item>
            <el-input :prefix-icon="Lock" v-model="form.password" show-password/>
          </el-form-item>
          <el-form-item>
            <el-button style="width: 100%" type="primary" @click="login">登录</el-button>
          </el-form-item>
        </el-form>
      </div>
    </div>
</template>

<script>
  import {Avatar,Lock} from '@element-plus/icons'
  import request from "../utils/request";
  export default {
    name: "Login",
    data(){
      return{
        form: {},
        Avatar:Avatar,
        Lock:Lock,
      }
    },
    methods:{
      login(){
        request.post('/user/login',this.form).then(res => {
          if(res.code === '0'){
            this.$message({
              type: 'success',
              message: '登录成功'
            })
            this.$router.push("/") //登录成更之后跳转回主页
          }else{
            this.$message({
              type: 'error',
              message: res.msg
            })
          }
        })
      }
    }
  }
</script>

<style scoped>

</style>

